package com.algorithm4;

import java.util.Arrays;

public class InsertionSort {
    public static void sort(int[] array){
        for(int i=1;i<array.length;i++){
            int j = i;
            int indexTemp = array[j];
            while(j>0 && array[j-1]>indexTemp){
                array[j] = array[j-1];
                j--;
            }
            if(j!=i){
                array[j] = indexTemp;
            }
            System.out.println(i+"-->array:"+ Arrays.toString(array));
        }
    }

    public static void main(String[] args){
        int[] array = new int[]{1,3,5,7,9,0,2,4,6,8,10,1,3,5,7,9};
        sort(array);
        System.out.println("result:"+ Arrays.toString(array));
    }

}
